package pl.edu.agh.linearalgebra.main;

import pl.edu.agh.linearalgebra.model.matrix.IMatrix;
import pl.edu.agh.linearalgebra.model.matrix.Matrix;

//klasa do odpalania programu
public class Main {

    public static void main(String[] args) {
        // @formatter:off - wylaczenie formatowania (patrz windows->preferences->java->editor->save actions - mozna wlaczyc i skonfigurowac formatter)
        IMatrix firstMatrix = new Matrix(new int[][] { 
                { 2, 4, 5, 7, 9 }, 
                { 1, 2, 4, 6, 8 }, 
                { 4, 12, 46, 9, 0 },
                { 9, 34, 6, 8, 1 } });
        IMatrix secondMatrix = new Matrix(new int[][]{ 
                { 12, 56, 7, 9, 0 }, 
                { 0, 4, 34, 5, 1 }, 
                { 9, 54, 0, 1, 4 }, 
                { 1, 1, 1, 2, 22 } });
        // @formatter:on
        IMatrix resultantMatrix;
        IMatrix stupidMatrix;
        int scalar = 5;

        resultantMatrix = firstMatrix.addition(secondMatrix);
        resultantMatrix.display();
        System.out.println();
        resultantMatrix = firstMatrix.multiplicationByScalar(scalar);
        resultantMatrix.display();
        System.out.println();
        firstMatrix.translation();
        firstMatrix.display();

    }

    // zostawilem stare metody - do usuniecia, jak nie beda Ci juz potrzebne

    public static void display(int x[][]) {
        for (int i = 0; i < x.length; i++) {
            for (int j = 0; j < x[i].length; j++) {
                System.out.print(x[i][j] + "\t");
            }
            System.out.println();
        }
    }

    // zwracanie wartosci za pomoca jednego z argumentow to podejsice bardzo
    // C++,
    // w Javie jezeli jest to mozliwe staramy sie zwracac zmieniona wartosc za
    // pomoca return,
    // zamiast modyfikacji jednego z argumetow
    //
    // wiec jak juz robilibysmy tego typu metode to lepiej napisac:
    // int[][] addition(int x[][], int y[][])
    // jest bardziej czytenie!
    //
    // (oczywiscie cala metoda i tak do wyrzucenia)
    public static void addition(int x[][], int y[][], int z[][]) {

        for (int i = 0; i < x.length; i++) {
            for (int j = 0; j < x[i].length; j++) {
                z[i][j] = x[i][j] + y[i][j];
            }
        }
    }

    public static void multiplicationByScalar(int x[][], int z[][], int a) {
        for (int i = 0; i < x.length; i++) {
            for (int j = 0; j < x[i].length; j++) {
                z[i][j] = x[i][j] * a;
            }
        }
    }

    public static void translation(int x[][], int z[][]) {
        for (int i = 0; i < x.length; i++) {
            for (int j = 0; j < x[i].length; j++) {
                z[j][i] = x[i][j];
            }
        }
    }

}
